package com.levenx.vo.support;

import com.levenx.constant.ResultStatus;
import com.levenx.vo.Result;

public class DefaultResult<T> implements Result<T> {

    private int status;

    private String massage;

    private T data;

    public DefaultResult() {
        this.status = ResultStatus.SUCCESS;
        this.massage = "SUCCESS";
        this.data = null;
    }

    public DefaultResult(T data) {
        this.status = ResultStatus.SUCCESS;
        this.massage = "SUCCESS";
        this.data = data;
    }

    public DefaultResult(int status, String massage, T data) {
        this.status = status;
        this.massage = massage;
        this.data = data;
    }

    public DefaultResult(int status, String massage) {
        this.status = status;
        this.massage = massage;
    }

    public boolean isSuccess() {
        return 0 == this.status;
    }

    public int status() {
        return this.status;
    }

    @Override
    public Result<?> ofStatus(int status, String massage) {
        this.status = status;
        this.massage = massage;
        return this;
    }


    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMassage() {
        return massage;
    }

    public void setMassage(String massage) {
        this.massage = massage;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "DefaultResult{" +
                "status=" + status +
                ", massage='" + massage + '\'' +
                ", data=" + data +
                '}';
    }
}
